<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/4/1
 * Time: 21:50
 */

namespace app\api\validate;


class IDConllection extends BaseValidate
{
    protected $rule = [
        'ids' => 'require|checkIDs'
    ];

    protected $message = [
        'ids' => 'ids必须为逗号分割的多个正整数'
    ];
    //ids = id1,id2
    protected function checkIDs($value){
        $values = explode(',', $value);
        if (empty($values)){
            return false;
        }
        foreach ($values as $id)
        {
            if (!$this->isPositiveInteger($id)){
                return false;
            }
        }
        return true;
    }
}